<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>new</title>
</head>
<body>
<script type="text/javascript">
function Car(id, name) {
	this.id = id;
	this.name = name;
}
Car.prototype = {
	getId: function() {
		return this.id;
	}
}
function _new(fn, ...args) {
	const obj = Object.create(fn.prototype);
	const context = fn.call(obj, ...args);
	return context instanceof fn ? context : obj;
}
const car1 = new Car(101, 'mm');
const car2 = _new(Car, 101, 'mm');
console.log(car1);
console.log(car2);
</script>
<script type="text/javascript">
</script>
</body>
</html>